import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { cardMetaDefaultProps } from './defaultProps';
import type { CardMetaOptions } from './type';

export interface CardMetaProps extends CardMetaOptions, HTMLAttributes<HTMLDivElement> {}

const CardMeta: FC<CardMetaProps> = (props) => {
  const { className, floated, aligned, children, forwardedRef, ...cardMetaProps } = props;

  return createElement(
    'div',
    {
      ref: forwardedRef,
      className: classNames(floated, { floated }, aligned, { aligned }, 'meta', className),
      ...cardMetaProps,
    },
    children,
  );
};

CardMeta.displayName = 'CardMeta';
CardMeta.defaultProps = cardMetaDefaultProps;

export default CardMeta;
